home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / AmiVoGL_MDEV.lha / src / draw.c < prev    next >
C/C++ Source or Header  |  1994-04-12  |  6KB  |  331 lines

  1. #include "vogl.h"
  2.  
  3. /*
  4.  * draw
  5.  *
  6.  * draw a line form the logical graphics position to the
  7.  * the world coordinates x, y, z.
  8.  *
  9.  */
  10. void draw(
  11.   float x,
  12.   float y,
  13.   float z)
  14. {
  15. Token    *tok;
  16. int    vx, vy;
  17. Vector    res;
  18.  
  19.  
  20. if (!vdevice.initialised)
  21. verror("draw: vogl not initialised");
  22.  
  23. if (vdevice.inobject) {
  24.     tok = newtokens(4);
  25.  
  26.     tok[0].i = DRAW;
  27.     tok[1].f = x;
  28.     tok[2].f = y;
  29.     tok[3].f = z;
  30.  
  31.     vdevice.cpW[V_X] = x;
  32.     vdevice.cpW[V_Y] = y;
  33.     vdevice.cpW[V_Z] = z;
  34.  
  35.     vdevice.cpVvalid = 0;
  36.  
  37.     return;
  38.     }
  39.  
  40. if (!vdevice.cpVvalid)
  41. multvector(vdevice.cpWtrans, vdevice.cpW, vdevice.transmat->m);
  42.  
  43. vdevice.cpW[V_X] = x;
  44. vdevice.cpW[V_Y] = y;
  45. vdevice.cpW[V_Z] = z;
  46. multvector(res, vdevice.cpW, vdevice.transmat->m);
  47.  
  48. if (vdevice.clipoff) {
  49.     vx = WtoVx(res);        /* just draw it */
  50.     vy = WtoVy(res);
  51.      
  52.     (*vdevice.dev.Vdraw)(vx, vy);
  53.  
  54.     vdevice.cpVx = vx;
  55.     vdevice.cpVy = vy;
  56.  
  57.     vdevice.cpVvalid = 0;
  58.     }
  59. else {
  60.     if (vdevice.cpVvalid)
  61.     quickclip(vdevice.cpWtrans, res);
  62.     else
  63.     clip(vdevice.cpWtrans, res);
  64.     }
  65.  
  66. vdevice.cpWtrans[V_X] = res[V_X];
  67. vdevice.cpWtrans[V_Y] = res[V_Y];
  68. vdevice.cpWtrans[V_Z] = res[V_Z];
  69. vdevice.cpWtrans[V_W] = res[V_W];
  70. }
  71.  
  72. /* ------------------------------------------------------------------------ */
  73.  
  74. /*
  75.  * draws
  76.  *
  77.  * draw a line form the logical graphics position to the
  78.  * the world coordinates x, y, z expressed as a short integer data type.
  79.  *
  80.  */
  81. void draws(
  82.   Scoord x,
  83.   Scoord y,
  84.   Scoord z)
  85. {
  86. draw((Coord)x, (Coord)y, (Coord)z);
  87. }
  88.  
  89. /* ------------------------------------------------------------------------ */
  90.  
  91.  
  92. /*
  93.  * drawi
  94.  *
  95.  * draw a line form the logical graphics position to the
  96.  * the world coordinates x, y, z expressed as an integer data type.
  97.  *
  98.  */
  99. void drawi(
  100.   Icoord x,
  101.   Icoord y,
  102.   Icoord z)
  103. {
  104. draw((Coord)x, (Coord)y, (Coord)z);
  105. }
  106.  
  107. /* ------------------------------------------------------------------------ */
  108.  
  109.  
  110.  
  111. /*
  112.  * draw2
  113.  *
  114.  * draw a line from the logical graphics position  to the
  115.  * the world coordinates x, y.
  116.  *
  117.  */
  118. void draw2(
  119.   float x,
  120.   float y)
  121. {
  122. if (!vdevice.initialised)
  123. verror("draw2: vogl not initialised");
  124.  
  125. draw(x, y, 0.0);
  126. }
  127.  
  128. /* ------------------------------------------------------------------------ */
  129.  
  130. /*
  131.  * draw2s
  132.  *
  133.  * draw a line from the logical graphics position  to the
  134.  * the world coordinates x, y expressed as a short integer data type.
  135.  *
  136.  */
  137. void draw2s(
  138.   Scoord x,
  139.   Scoord y)
  140. {
  141. draw2((Coord)x, (Coord)y);
  142. }
  143.  
  144. /* ------------------------------------------------------------------------ */
  145.  
  146.  
  147. /*
  148.  * draw2i
  149.  *
  150.  * draw a line from the logical graphics position  to the
  151.  * the world coordinates x, y expressed as an integer data type.
  152.  *
  153.  */
  154. void draw2i(
  155.   Icoord x,
  156.   Icoord y)
  157. {
  158. draw2((Coord)x, (Coord)y);
  159. }
  160.  
  161. /* ------------------------------------------------------------------------ */
  162.  
  163. /*
  164.  * rdr
  165.  *
  166.  * 3D relative draw from the logical graphics position by dx, dy, dz.
  167.  * This is the same as the VOGLE routine rdraw.
  168.  *
  169.  */
  170. void rdr(
  171.   float dx,
  172.   float dy,
  173.   float dz)
  174. {
  175. if (!vdevice.initialised) 
  176. verror("rdr: vogl not initialised");
  177.  
  178. draw((vdevice.cpW[V_X] + dx), (vdevice.cpW[V_Y] + dy), (vdevice.cpW[V_Z] + dz));
  179. }
  180.  
  181. /* ------------------------------------------------------------------------ */
  182.  
  183. /*
  184.  * rdrs
  185.  *
  186.  * 3D relative draw from the logical graphics position by dx, dy, dz
  187.  * expressed as a short integer data type.
  188.  *
  189.  */
  190. void rdrs(
  191.   Scoord dx,
  192.   Scoord dy,
  193.   Scoord dz)
  194. {
  195. rdr((Coord)dx, (Coord)dy, (Coord)dz);
  196. }
  197.  
  198. /* ------------------------------------------------------------------------ */
  199.  
  200. /*
  201.  * rdri
  202.  *
  203.  * 3D relative draw from the logical graphics position by dx, dy, dz
  204.  * expressed as an integer data type.
  205.  *
  206.  */
  207. void rdri(
  208.   Icoord dx,
  209.   Icoord dy,
  210.   Icoord dz)
  211. {
  212. rdr((Coord)dx, (Coord)dy, (Coord)dz);
  213. }
  214.  
  215. /* ------------------------------------------------------------------------ */
  216.  
  217.  
  218. /*
  219.  * rdr2
  220.  *
  221.  * 2D relative draw from the logical graphics position by dx, dy.
  222.  * This is the same as the VOGLE routine rdraw2.
  223.  *
  224.  */
  225. void rdr2(
  226.   float dx,
  227.   float dy)
  228. {
  229. if (!vdevice.initialised) 
  230. verror("rdr2: vogl not initialised");
  231.  
  232. draw((vdevice.cpW[V_X] + dx), (vdevice.cpW[V_Y] + dy), 0.0);
  233. }
  234.  
  235. /* ------------------------------------------------------------------------ */
  236.  
  237.  
  238. /*
  239.  * rdr2s
  240.  *
  241.  * 3D relative draw from the logical graphics position by dx, dy
  242.  * expressed as a short integer data type.
  243.  *
  244.  */
  245. void rdr2s(
  246.   Scoord dx,
  247.   Scoord dy)
  248. {
  249. rdr2((Coord)dx, (Coord)dy);
  250. }
  251.  
  252. /* ------------------------------------------------------------------------ */
  253.  
  254. /*
  255.  * rdr2i
  256.  *
  257.  * 3D relative draw from the logical graphics position by dx, dy
  258.  * expressed as an integer data type.
  259.  *
  260.  */
  261. void rdr2i(
  262.   Icoord dx,
  263.   Icoord dy)
  264. {
  265. rdr2((Coord)dx, (Coord)dy);
  266. }
  267.  
  268. /* ------------------------------------------------------------------------ */
  269.  
  270.  
  271. /*
  272.  * bgnline
  273.  *
  274.  *     Flags that all v*() routine points will be building up a line list.
  275.  */
  276. void bgnline(void)
  277. {
  278. if (vdevice.bgnmode != NONE)
  279. verror("vogl: bgnline mode already belongs to some other bgn routine");
  280.  
  281. vdevice.bgnmode = VLINE;
  282. vdevice.save = 1;
  283. }
  284.  
  285. /* ------------------------------------------------------------------------ */
  286.  
  287. /*
  288.  * endline
  289.  *
  290.  *     Flags that all v*() routine points will be simply setting the 
  291.  *     current position.
  292.  */
  293. void endline(void)
  294. {
  295. vdevice.bgnmode = NONE;
  296. vdevice.save = 0;
  297. }
  298.  
  299. /* ------------------------------------------------------------------------ */
  300.  
  301. /*
  302.  * bgnclosedline
  303.  *
  304.  *     Flags that all v*() routine points will be building up a line list.
  305.  */
  306. void bgnclosedline(void)
  307. {
  308. if (vdevice.bgnmode != NONE)
  309. verror("vogl: bgncloseline mode already belongs to some other bgn routine");
  310.  
  311. vdevice.bgnmode = VCLINE;
  312. vdevice.save = 1;
  313. }
  314.  
  315. /* ------------------------------------------------------------------------ */
  316.  
  317. /*
  318.  * endclosedline
  319.  *
  320.  *     Flags that all v*() routine points will be simply setting the 
  321.  *     current position.
  322.  */
  323. void endclosedline(void)
  324. {
  325. vdevice.bgnmode = NONE;
  326. draw(vdevice.savex, vdevice.savey, vdevice.savez);
  327. }
  328.  
  329. /* ------------------------------------------------------------------------ */
  330.  
  331.